<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script type="text/javascript" src="../js/vue.min.js"></script>
    <script type="text/javascript" src="../js/vue-router.js"></script>
    <title>嵌套路由</title>
  </head>
  <body>
    <div id="app">
      <router-link to="/a">嵌套路由</router-link>
      <router-link to="/a/c1">嵌套路由</router-link>
      <router-link to="/a/c2">嵌套路由</router-link>
      <router-view></router-view>
    </div>
    <script type="text/javascript">
      const t1 = {
        template: `<div style="width:400px;height:200px;border:blue 1px solid">
          index
        <hr/>
        <router-view></router-view>
        </div>`,
      };
      const t2 = {
        template: `<div>t2</div>`,
      };
      const t3 = {
        template: `<div>t3</div>`,
      };
      // 2.定义路由规则
      const myRouter = new VueRouter({
        routes: [
          {
            path: "/a",
            component: t1,
            children: [
              {
                path: "c1",
                component: t2,
              },
              {
                path: "c2",
                component: t3,
              },
            ],
          },
        ],
      });
      var vue = new Vue({
        el: "#app",
        router: myRouter,
      });
    </script>
  </body>
</html>
